extends layout

block append pageStyles

block header
  header(class="header navbar navbar-fixed-top", role="banner")
    div(class="container")
      <!-- Only visible on smartphones, menu toggle -->
      ul(class="nav navbar-nav")
        li(class="nav-toggle")
          a(href="javascript:void(0);" title="")
            i(class="icon-reorder")

      <!-- Logo -->
      a(class="navbar-brand" href="/")
        strong 系统控制台
      <!-- /logo -->

      <!-- Sidebar Toggler -->
      a(href="#" class="toggle-sidebar bs-tooltip" data-placement="bottom" data-original-title="Toggle navigation")
        i(class="icon-reorder")
      <!-- /Sidebar Toggler -->

      <!-- Top Left Menu -->
      ul(class="nav navbar-nav navbar-left hidden-xs hidden-sm")
        li
          a(href="#") Dashboard
      <!-- /Top Left Menu -->

      <!-- Top Right Menu -->
      ul(class="nav navbar-nav navbar-right")
        <!-- Notifications -->
        li(class="dropdown")
          a(href="#", class="dropdown-toggle", data-toggle="dropdown")
            i(class="icon-warning-sign")
            span(class="badge") 5
          ul(class="dropdown-menu extended notification")
            li(class="title")
              p You have 5 new notifications
            li
              a(href="javascript:void(0);")
                span(class="label label-success")
                  i(class="icon-plus")
                span(class="message") New user registration.
                span(class="time") 1 mins
            li
              a(href="javascript:void(0);")
                span(class="label label-success")
                  i(class="icon-plus")
                span(class="message") New user registration.
                span(class="time") 1 mins
            li
              a(href="javascript:void(0);")
                span(class="label label-success")
                  i(class="icon-plus")
                span(class="message") New user registration.
                span(class="time") 1 mins
            li(class="footer")
              a(href="javascript:void(0);") View all notifications
      
        <!-- User Login Dropdown -->
        li(class="dropdown user")
          a(href="#", class="dropdown-toggle", data-toggle="dropdown")
            <!--<img alt="" src="assets/img/avatar1_small.jpg" />-->
            i(class="icon-male")
            span(class="username")  何磊 
            i(class="icon-caret-down small")
          
          ul(class="dropdown-menu")
            li
              a(href="pages_user_profile.html")
                i(class="icon-user")
                | My Profile
            li
              a(href="pages_calendar.html")
                i(class="icon-calendar") 
                | My Calendar
            li
              a(href="#")
                i(class="icon-tasks") 
                | My Tasks
            li(class="divider")
            li
              a(href="login.html")
                i(class="icon-key") 
                | Log Out
        <!-- /user login dropdown -->

block workspace
  div(id="container")
    div(id="sidebar", class="sidebar-fixed")
      block sidebar
        div(id="sidebar-content")
          <!--=== Navigation ===-->
          ul(id="nav")
            li(class="current")
              a(href="/console/accounts/")
                i(class="icon-dashboard")
                | 基本信息
            li()
              a(href="/console/clients/")
                i(class="icon-desktop")
                | 实例
            li()
              a(href="/console/users/")
                i(class="icon-user")
                | 用户
            li
              a(href="javascript:void(0);")
                i(class="icon-desktop")
                | 参数设置
                span(class="label label-info pull-right") 2
              ul(class="sub-menu")
                li
                  a(href="#")
                    i(class="icon-angle-right")
                    | 工作时间
                li
                  a(href="#")
                    i(class="icon-angle-right")
                    | 提醒
        div(id="divider", class="resizeable")
    div(id="content")
      div(class='container')
        block crumbs
          div(class="crumbs")
            ul(id="breadcrumbs", class="breadcrumb")
              li
                i(class="icon-home")
                a(href="#") 控制台首页
              li(class="current")
                a(href="#" title="") #{title}
            block crumbsToolbar
                  
        block content                

block append pageScripts
  <!-- App -->
  script(type="text/javascript", src="/assets/js/app.js")
  script(type="text/javascript", src="/assets/js/plugins.js")
  script(type="text/javascript", src="/assets/js/plugins.form-components.js")

  script(type="text/javascript").
      $(document).ready(function(){
          "use strict";

          App.init(); // Init layout and core plugins
          Plugins.init(); // Init all plugins
          FormComponents.init(); // Init all form-specific plugins

          //Ajax interceptor
          $( document ).ajaxSend(function( event, xhr, settings ) {
              event.preventDefault();

              var targetLocation = settings.url;
              if(targetLocation.hostname !== location.hostname){
                  console.log("External ajax call - Ignore it");
              }else{
                  //call to current host - detect if jwt cookie expires
                  var jwtToken = Cookies.get('sjwt');
                  if(jwtToken){
                      //Set request header
                      xhr.setRequestHeader('Authorization', 'bearer ' + jwtToken);
                  }else{
                      //Not logged in, retrieve or refresh token
                      console.log("token does not exist");
                  }
              }
          });
      }); 
